<?php
/**
 * Description: 获取手机号的状态
 * User: devforma
 * Date: 15/7/9
 * Time: 12:05
 */

class GetPhoneStatus implements iController {

    /**
     * api请求处理主函数
     * @param array $queryArgs 就是$_REQUEST变量
     * @return array api返回结果，必须含response_code
     */
    public function output($queryArgs) {
        global $uddb;

        if (empty($queryArgs['mobile_num']) || !validatePhone($queryArgs['mobile_num']))
            return genOutput(1000);

        $row = $uddb->getRow('SELECT `ID`, `user_pass` FROM `user_auth_info` WHERE `phone`=:phone',
            array(':phone' => $queryArgs['mobile_num']));

        if (empty($row)) {
            $status = 0;
        } elseif (!empty($row->user_pass)) {
            $status = 1;
        } else {
            $status = 2;
        }

        return genOutput(1, array(
            'status' => $status
        ));
    }
}